<?php slot('js_insideLoadFunction')?>
ADMIN_FORM.init();
CANDIDATE.initForm();
CANDIDATE.addChildLanguage();
	$('#rdSalary_payed').click(function(){ //payed
		$('div.salary-payed').show();
		$('div.salary-to').hide()
	});
	$('#rdSalary_limit').click(function(){ //limit
		$('div.salary-payed').hide();
		$('div.salary-to').show()
	});
	$('#rdSalary_discuss').click(function(){ //discuss
		$('div.salary-payed').hide();
		$('div.salary-to').hide()
	});
	$('#rdSalary_<?php echo intval($data['rdSalary'])==1?'payed':(intval($data['rdSalary']) == 2 ?'limit':'discuss')?>').trigger('click');
<?php end_slot()?>
<?php slot('js_outsideLoadFunction')?>
<script type="text/javascript">
function fCHK(){
	var datestr = $('#Jobs_date_from').val();
	var year = datestr.substring(6,datestr.length);
	var month = datestr.substring(3,5);
	var day = datestr.substring(0,2);
	var dFrom = new Date(year, month, day);

	var datestr = $('#Jobs_date_to').val();
	var year = datestr.substring(6,datestr.length);
	var month = datestr.substring(3,5);
	var day = datestr.substring(0,2);
	var dTo = new Date(year, month, day);

	
	if(dFrom > dTo){
		alert('<?php echo __('error_date_from', null, 'company_jobs')?>');
		$('#Jobs_date_from').focus();
		$('#Jobs_date_from').focus();
		return false;
	}

	var aFrom = $('#Jobs_age_from');
	var aTo = $('#Jobs_age_to');
	if(parseInt(aFrom.val()) >= parseInt(aTo.val())){
		alert('<?php echo __('error_age_from', null, 'company_jobs')?>');
		aFrom.focus();
		aFrom.focus();
		return false;
	}

	var rFrom = $('#Jobs_number_recruitment');
	var rTo = $('#Jobs_number_recruited');
	if(parseInt(rFrom.val()) < parseInt(rTo.val())){
		alert('<?php echo __('error_recruit_from', null, 'company_jobs')?>');
		rFrom.focus();
		rFrom.focus();
		return false;
	}

	var sFrom = $('#Jobs_salary_from');
	var sTo = $('#Jobs_salary_to');
	if(parseInt(MONEY.reverse(sFrom.val())) > 0 && parseInt(MONEY.reverse(sFrom.val())) >= parseInt(MONEY.reverse(sTo.val())) && parseInt(MONEY.reverse(sTo.val())) > 0 && $('#rdSalary_limit').is(':checked')){
		alert('<?php echo __('error_salary_from', null, 'company_jobs')?>');
		sFrom.focus();
		sFrom.focus();
		return false;
	}
	$('input.money').each(function(){
		var $ob = $(this);
		$ob.val(MONEY.reverse($ob.val()));
	});
	return true;
}
</script>
<?php end_slot();?>
<div class="box-navigation">
	<?php echo $data['navigation']?>
</div>
<div class="clr"></div>
<div class="box-content">
	<form action="?action_name=<?php echo $data['action']?>" method="post" name="form_main" id="form_main" onsubmit="return fCHK();">
		<?php echo $form['_csrf_token']?>
		<div class="clr"></div>
		<div class="box-content-main "><?php echo $form->renderGlobalErrors()?>
			<div class="message"><?php echo empty($data['result'])?'':$data['result']?></div><div class="note"><?php echo __('is_require',null, 'table_list')?></div>
			<div class="clr"></div>
			<table class="table-list table-form" cellspacing="0" cellpadding="0" border="0">
				<tr class="class1">
					<td class="label"><?php echo __('label_company_id',null,'company_jobs')?><span class="required">*</span></td>
					<td class="input">
						<?php echo $form['company_id']->render(array('class'=>'required  nav-top' , 'data-require'=> 'selected'))?>
						<span class="error" id="type_error"><?php echo __('selected', null, 'table_list')?></span>
					</td>
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_position_id',null,'company_jobs')?><span class="required">*</span></td>
					<td class="input">
						<?php echo $form['position_id']->render(array('class'=>'required' , 'data-require'=> 'selected'))?>
						<span class="error" id="type_error"><?php echo __('selected', null, 'table_list')?></span>
					</td>
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_title',null,'company_jobs')?><span class="required">*</span></td>
					<td class="input">
						<?php echo $form['title']->render(array('class'=>'form-text required', 'data-require'=> 'not-empty'))?>
						<span class="error" id="type_error"><?php echo __('not_empty', null, 'table_list')?></span>
					</td>
					
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_major_text',null,'company_jobs')?></td>
					<td class="input">
						<?php echo $form['major_text']->render(array('class'=>'form-text'))?>
					</td>
					
				</tr>
				<tr class="class1" style="display: none">
					<td class="label"><?php echo __('label_short_description',null,'company_jobs')?></td>
					<td class="input">
						<?php echo $form['short_description']->render()?>
						
					</td>
					
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_description',null,'company_jobs')?></td>
					<td class="input">
						<?php echo $form['description']->render(array('class'=>'editor'))?>
					</td>
					
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_date',null,'company_jobs')?><span class="required">*</span></td>
					<td class="input">
						<?php echo $form['date_from']->render(array('class'=>'date date-picker-year required','data-require'=> 'not-empty'))?>
						<?php echo __('label_date_to', null, 'company_jobs')?>
						<?php echo $form['date_to']->render(array('class'=>'date date-picker-year required','data-require'=> 'not-empty'))?>
						<span class="error" id="type_error"><?php echo __('error_date_required', null, 'company_jobs')?></span>
					</td>
					
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_number_recruitment',null,'company_jobs')?><span class="required">*</span></td>
					<td class="input">
						<?php echo $form['number_recruitment']->render(array('class'=>'number required', 'data-require'=> 'not-empty'))?>
						<span class="error" id="type_error"><?php echo __('not_empty', null, 'table_list')?></span>
					</td>
					
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_number_recruited',null,'company_jobs')?><span class="required">*</span></td>
					<td class="input">
						<?php echo $form['number_recruited']->render(array('class'=>'number required','data-require'=> 'not-empty'))?>
						<span class="error" id="type_error"><?php echo __('not_empty', null, 'table_list')?></span>
					</td>
					
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_age',null,'company_jobs')?><span class="required">*</span></td>
					<td class="input">
						<?php echo $form['age_from']->render(array('class'=>'date required', 'data-require'=> 'selected'))?>
						<?php echo __('label_age_to',null,'company_jobs')?>
						<?php echo $form['age_to']->render(array('class'=>'date required', 'data-require'=> 'selected'))?>
						<span class="error" id="type_error"><?php echo __('error_age_more_than', null, 'company_jobs')?></span>
					</td>
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_require_gender',null,'company_jobs')?></td>
					<td class="input">
						<?php echo $form['require_gender']->render(array('class'=>'fomr-text'))?>
						
					</td>
					
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_multi_levels',null,'company_jobs')?></td>
					<td class="input">
						<?php 
						$count_all_level = count($data['list']['levels']);
						$count_for_level = ceil($count_all_level / 3);?>
						<div style="float: left; width: 220px;">
						<?php for($i = 0; $i < $count_for_level; $i ++):
							$per = $data['list']['levels'][$i];?>						
							<input type="checkbox" class="promotion" <?php echo $data['levels'][$per['id']]?> value="<?php echo $per['id']?>" name="levels[]"/><label><?php echo $per['name']?></label><br/>
						<?php endfor; ?>
						</div>
						<div style="float: left; width: 220px;">
						<?php for($i = $count_for_level; $i < $count_for_level*2; $i ++):
							$per = $data['list']['levels'][$i];?>						
							<input type="checkbox" class="promotion" <?php echo $data['levels'][$per['id']]?> value="<?php echo $per['id']?>" name="levels[]"/><label><?php echo $per['name']?></label><br/>
						<?php endfor; ?>
						</div>
						<div style="float: left; width: 220px;">
						<?php for($i = $count_for_level*2; $i < $count_all_level; $i ++):
							$per = $data['list']['levels'][$i];?>						
							<input type="checkbox" class="promotion" <?php echo $data['levels'][$per['id']]?> value="<?php echo $per['id']?>" name="levels[]"/><label><?php echo $per['name']?></label><br/>
						<?php endfor; ?>
						</div>
						<div class="clr"></div>
					</td>
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_multi_major',null,'company_jobs')?></td>
					<td class="input" style="border: 1px dotted #ccc;">
						<?php 
						$count_for_major = 0;
						foreach ($data['list']['majors'] as $pro):
							if(count($pro['MasterMajors'])):?>
						<div style="float: left; width: 250px;margin-top:20px;">
							<span><?php echo $pro['name']?></span><br/>
							<?php foreach($pro['MasterMajors'] as $per):?>
								<input style="margin-left:20px;" type="checkbox" class="promotion" <?php echo $data['majors'][$per['id']]?> value="<?php echo $per['id']?>" name="majors[]"/><label><?php echo $per['name']?></label><br/>
							<?php endforeach;?>
							
						</div>
						<?php	endif; 
						 echo (++$count_for_major % 3 == 0) ? '<div class="clr"></div>' : '' ?>
						<?php 	endforeach;?>
					</td>
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_language',null,'company_jobs')?></td>
					<td class="input">
						<table class="create-child" border="1" cellspacing="0" cellpadding="0" style="width:625px;"> 
							<tr>
								<td class="header"><?php echo __('language_name', null, 'company_jobs')?></td>
								<td class="header"><?php echo __('language_level', null, 'company_jobs')?></td>
								<td class="header"><?php echo __('language_description', null, 'company_jobs')?></td>
								<td class="header"><?php echo __('language_action', null, 'company_jobs')?></td>
							</tr>
							
							<?php 
							
							for ($i=0; $i< count($data['child']['languages']); $i++):
							$work = $data['child']['languages'][$i];
							$workDes = $data['child']['language_des'][$i];
							
							?>
							<tr>
								<td class="child"><?php echo $data['child']['language_list'][$work['foreign_language_id']]['name']?></td>
								<td class="child"><?php echo $data['child']['language_level_list'][$work['foreign_language_level_id']]['name']?></td>
								<td class="child"><?php echo $workDes?></td>
								<td class="child-control">
									<a href="#" class="remove-child" title="">&nbsp;</a>
									<input name="languages[]" type="hidden" value="<?php echo $work['foreign_language_id'].';'.$work['foreign_language_level_id']?>">
									<input name="language_des[]" type="hidden" value="<?php echo $workDes?>">
								</td>
							</tr>
							<?php endfor;?>
							
							<tr>
								<td class="child" style="text-align: center">
									<select style="width:120px;"  name="childlanguage" class="child required" id="input_language" data-error="<?php echo __('error_language', null, 'company_jobs')?>">
										<option value="-1"><?php echo __('option_select', null, 'table_list')?></option>
										<?php foreach($data['child']['language_list'] as $k => $v):?>
										<option value="<?php echo $k?>"><?php echo $v['name']?></option>
										<?php endforeach;?>
									</select>
								</td>
								<td class="child" style="text-align: center">
									<select style="width:120px;"  name="childlanguageLevel" class="child required" id="input_language_level" data-error="<?php echo __('error_language_level', null, 'company_jobs')?>">
										<option value="-1"><?php echo __('option_select', null, 'table_list')?></option>
									</select>
								</td>
								
								<td class="child"><textarea name="childlanguagedes" class="" id="input_language_description" style="width:200px;height:50px;"></textarea></td>
								<td class="child-control"><a href="#" class="add-child add-child-language" title="">&nbsp;</a></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_multi_location',null,'company_jobs')?></td>
					<td class="input">
						<?php 
						$count_all_city = count($data['list']['cities']);
						$count_for_city = ceil($count_all_city / 5);?>
						<div style="float: left; width: 125px;">
						<?php for($i = 0; $i < $count_for_city; $i ++):
							$per = $data['list']['cities'][$i];?>						
							<input type="checkbox" class="promotion" <?php echo $data['cities'][$per['id']]?> value="<?php echo $per['id']?>" name="cities[]"/><label><?php echo $per['name']?></label><br/>
						<?php endfor; ?>
						</div>
						<div style="float: left; width: 125px;;">
						<?php for($i = $count_for_city; $i < $count_for_city*2; $i ++):
							$per = $data['list']['cities'][$i];?>						
							<input type="checkbox" class="promotion" <?php echo $data['cities'][$per['id']]?> value="<?php echo $per['id']?>" name="cities[]"/><label><?php echo $per['name']?></label><br/>
						<?php endfor; ?>
						</div>
						<div style="float: left; width: 125px;;">
						<?php for($i = $count_for_city*2; $i < $count_for_city*3; $i ++):
							$per = $data['list']['cities'][$i];?>						
							<input type="checkbox" class="promotion" <?php echo $data['cities'][$per['id']]?> value="<?php echo $per['id']?>" name="cities[]"/><label><?php echo $per['name']?></label><br/>
						<?php endfor; ?>
						</div>
						<div style="float: left; width: 125px;;">
						<?php for($i = $count_for_city*3; $i < $count_for_city*4; $i ++):
							$per = $data['list']['cities'][$i];?>						
							<input type="checkbox" class="promotion" <?php echo $data['cities'][$per['id']]?> value="<?php echo $per['id']?>" name="cities[]"/><label><?php echo $per['name']?></label><br/>
						<?php endfor; ?>
						</div>
						<div style="float: left; width: 125px;;">
						<?php for($i = $count_for_city*4; $i < $count_all_city; $i ++):
							$per = $data['list']['cities'][$i];?>						
							<input type="checkbox" class="promotion" <?php echo $data['cities'][$per['id']]?> value="<?php echo $per['id']?>" name="cities[]"/><label><?php echo $per['name']?></label><br/>
						<?php endfor; ?>
						</div>
						<div class="clr"></div>
					</td>
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_require_year',null,'company_jobs')?></td>
					<td class="input">
						<?php echo $form['require_year_experience']->render(array('class'=>'number'))?>
					</td>
					
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_require_description',null,'company_jobs')?></td>
					<td class="input">
						<?php echo $form['require_description']->render(array('class'=>'editor'))?>
					</td>
					
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_salary',null,'company_jobs')?></td>
					<td class="input">
						<input type="radio" name="rdSalary" value="1" id="rdSalary_payed" /><?php echo __('label_salary_payed',null,'company_jobs')?>
						<input type="radio" name="rdSalary" value="2" id="rdSalary_limit"/><?php echo __('label_salary_limit',null,'company_jobs')?>
						<input type="radio" name="rdSalary" value="3" id="rdSalary_discuss" checked/><?php echo __('label_salary_discuss',null,'company_jobs')?>
						<div class="salary-payed" style="display: none">
							<?php echo $form['salary_payed']->render(array('class'=>'number salary-payed money'))?>
						</div>
						<div class="salary-to" style="display: none">
							<?php echo $form['salary_from']->render(array('class'=>'number salary-from money'))?>
								&nbsp;<?php echo __('label_salary_to',null,'company_jobs')?>
							<?php echo $form['salary_to']->render(array('class'=>'number salary-to money'))?>
						</div>
					</td>
					
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_probation_time',null,'company_jobs')?></td>
					<td class="input"><?php echo $form['probation_time']->render(array('class'=>'number'))?></td>
					
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_probation_salary',null,'company_jobs')?></td>
					<td class="input"><?php echo $form['probation_salary']->render(array('class'=>'number'))?></td>
					
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_benefit',null,'company_jobs')?></td>
					<td class="input">
						<?php echo $form['benefit']->render(array('class'=>'editor'))?>
					</td>
					
				</tr>
				<tr class="class1">
					<td class="label"><?php echo __('label_is_recruit',null,'company_jobs')?></td>
					<td class="input"><?php echo $form['is_recruit']->render(array('class'=>'required'))?></td>
					
				</tr>
				<tr class="class1" style="display: none">
					<td class="label"><?php echo __('is_enabled',null,'table_list')?></td>
					<td class="input"><?php echo $form['is_enabled']->render(array('class'=>'required'))?></td>
					
				</tr>
				<tr class="class1" style="background:#fff">
					<td class="label">&nbsp;</td>
					<td class="input"><input type="button" id="button_submit" data-error="<?php echo __('submit_error', null, 'table_list')?>" name="button_submit" class="button" value="<?php echo $data['button_action']?>"/></td>
					
				</tr>
			</table>
		</div>


		<div class="clr"></div>
		<div class="control-back"><a href="<?php echo $data['redirect']?>" title="<?php echo __('control_back', null, 'table_list')?>" alt="<?php echo __('control_back', null, 'table_list')?>"><?php echo __('control_back', null, 'table_list')?></a></div>
	</form>
</div>